﻿@using DCMS.Web.Extensions;
@using DCMS.Web.Framework;
@using DCMS.Web.Framework.UI;
@using DCMS.ViewModel.Models.Finances;

@model PaymentReceiptBillModel

<input asp-for="Id" type="hidden" />
<input asp-for="ManufacturerId" type="hidden" />
<input asp-for="TotalAmount" type="hidden" />
<input asp-for="TotalDiscountAmount" type="hidden" />
<input asp-for="TotalPaymentedAmount" type="hidden" />
<input asp-for="TotalArrearsAmount" type="hidden" />
<input asp-for="TotalDiscountAmountOnce" type="hidden" />
<input asp-for="TotalReceivableAmountOnce" type="hidden" />
<input asp-for="TotalAmountOwedAfterReceipt" type="hidden" />
<input asp-for="BillTypeEnumId" type="hidden" />


@if (!ViewData.ModelState.IsValid)
{
    <div class="alert alert-warning alert-dismissable mt10 mb10">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <div asp-validation-summary="All"></div>
    </div>
}

@if (Model.AuditedStatus || Model.ReversedStatus)
{
    @await Html.PartialAsync("_Watermark")
}

<div class="row">
    <div class="col-sm-3">
        <div class="input-group">
            <dcms-input asp-for="ManufacturerName" class="form-control" placeholder="供应商..." asp-readonly="@(Model.AuditedStatus)" />
            <span class="input-group-btn">
                <button id="btn_search_manufacturer" type="button" class="btn btn-default" @(Model.AuditedStatus ? "disabled" : "")>
                    <span class="glyphicon glyphicon-search"></span>
                </button>
            </span>
        </div>
    </div>

    <div class="col-sm-2">
        <a class="btn btn-primary btn-block" href="javascript:;" id="loadOweCashBills"><i class="fa fa-undo mr5"></i> 加载欠款单据</a>
    </div>

    <div class="col-sm-2">
        <dcms-select asp-for="Draweer" asp-items="@Model.Draweers" asp-default="付款人" asp-disabled="@(Model.AuditedStatus)" />
    </div>

    <div class="col-sm-2">
        <dcms-editor asp-for="CreatedOnUtc" placeholder="开单日期..." asp-disabled="@(Model.AuditedStatus)" />
    </div>
    <div class="col-sm-3">
        <dcms-input asp-for="Remark" class="form-control" placeholder="备注..." asp-readonly="@(Model.AuditedStatus)" />
    </div>

</div>


@if (Model.Id != 0 && !string.IsNullOrEmpty(@Model.BillBarCode))
{
    <div class="row mtn mb10">
        <div class="col-md-3 pt20">
            <div class="form-group mbn">
                <lable class="col-lg-3 control-label">单据编号：</lable>
                <div class="col-lg-9">
                    <input asp-for="BillNumber" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
                </div>
            </div>
        </div>
        <div class="col-md-3 pt20">
            <div class="form-group mbn">
                <lable class="col-lg-3 control-label">制单：</lable>
                <div class="col-lg-9">
                    <input asp-for="MakeUserName" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
                </div>
            </div>
        </div>
        <div class="col-md-3 pt20">
            <div class="form-group mbn">
                <lable class="col-lg-3 control-label">审核：</lable>
                <div class="col-lg-9">
                    <input asp-for="AuditedUserName" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <img class="media-object mn thumbnail pull-right" src="@Model.BillBarCode" />
        </div>
    </div>
}

<div class="row mt10 mb10">
    <div class="col-md-12">
        <table id="PaymentReceiptItems" class="table table-striped table-bordered table-hover"></table>
    </div>
</div>

<div class="row mt20" id="PaymentReceiptItems_Partial_Form">
    <div class="col-sm-12">
        <label asp-for="DiscountAmount" asp-postfix=":" class="pull-left control-label mr10" />
        <div class="pull-left">
            <dcms-input asp-for="DiscountAmount" class="form-control-bb input-sm pbn pln prn" placeholder="本次优惠金额..." asp-readonly="@(Model.AuditedStatus)" />
        </div>

        <!--//////////以下块为收款账户引用//////////-->
        <div id="CollectionAccountBox">
            @foreach (var acc in Model.PaymentReceiptBillAccountings)
            {
                <span class="pull-left control-label mr10">@acc.Name:</span>
                <div class="pull-left">
                    <input class="form-control-bb input-sm-bb pbn pln prn ptn h-30" data-val="true" id="CollectionAmount_@acc.AccountingOptionId" name="CollectionAmount" type="text" data-codetype="@acc.AccountCodeTypeId" data-account="@acc.AccountingOptionId" value="@acc.CollectionAmount.ToString("0.00")" @(Model.AuditedStatus ? "readonly='readonly'" : "")>
                </div>
            }
        </div>

        <div class="pull-left mr10">
            <button id="Accounting_AsyncSearchSelectPopup" type="button" class="btn btn-default btn-sm" @((Model.AuditedStatus) || (Model.PaymentReceiptBillAccountings.Count <= 0) ? "disabled" : "")>
                <span class="glyphicon glyphicon-check"></span> 更改付款账户
            </button>
        </div>

        <!--////////////////////-->
        <label asp-for="AmountOwedAfterReceipt" asp-postfix=":" class="pull-left control-label mr10" />
        <div class="pull-left">
            <input asp-for="AmountOwedAfterReceipt" class="form-control-bb input-sm pbn pln prn" readonly="readonly" placeholder="剩余金额..." />
        </div>

    </div>
</div>

@*打印区域*@
<div id="printData">
</div>
